<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Card-3D</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            height: 100vh;
            background: #ECF0F1;
            /* 需要在容器的父元素上设置，距离屏幕的透视距离 */
            -webkit-perspective: 500px;
            perspective: 500px;
        }

        .wrap {
            position: relative;
            /* 在部分手机浏览器上有兼容性问题 */
            width: clamp(200px, 50vw, 400px);
            height: clamp(200px, 50vw, 400px);
            /* 垂直水平居中 */
            margin: auto;
            -webkit-transition: all 1s;
            transition: all 1s;
            /* 规定其子元素按照在三维空间中展示 */
            -webkit-transform-style: preserve-3d;
            transform-style: preserve-3d;
        }

        .wrap:hover {
            -webkit-transform: rotateY(180deg);
            transform: rotateY(180deg);
        }

        .front {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 10px;
            color: #fff;
            background: #1ABC9C;
            display: flex;
            justify-content: center;
            align-items: center;
            filter: drop-shadow(2px 2px 10px #ccc);
            /* 让正面div的背面不可见 */
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
        }

        .back {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 10px;
            background: #16A085;
            display: flex;
            justify-content: center;
            align-items: center;
            color: #fff;
            filter: drop-shadow(2px 2px 10px #ccc);
            /* 让背面div先翻转180度 */
            -webkit-transform: rotateY(180deg);
            transform: rotateY(180deg);
        }
    </style>
</head>

<body ontouchstart>
    <div class="wrap">
        <div class="front">Hello CSS3</div>
        <div class="back">I'm Jason</div>
    </div>
</body>

</html>